#ifndef _UART_
#define _UART_
              
#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "base_types.h"
#include "cw32f003.h"
#include "cw32f003_uart.h"

//UART1
#define  USART1                         CW_UART1
#define  USART1_CLK                     RCC_APB2_PERIPH_UART1
#define  USART1_APBClkENx               RCC_APBPeriphClk_Enable2
#define  USART1_BaudRate                115200
#define  USART1_UclkFreq                8000000
//UART2
#define  USART2                         CW_UART2
#define  USART2_CLK                     RCC_APB1_PERIPH_UART2
#define  USART2_APBClkENx               RCC_APBPeriphClk_Enable1
#define  USART2_BaudRate                115200
#define  USART2_UclkFreq                8000000

//UART1 GPIO (rx=>PC4 tx=>PB1)
#define  USART1_TX_GPIOB_CLK            RCC_AHB_PERIPH_GPIOB
#define  USART1_RX_GPIOC_CLK            RCC_AHB_PERIPH_GPIOC
#define  USART1_TX_GPIO_PORT            CW_GPIOB
#define  USART1_TX_GPIO_PIN             GPIO_PIN_1
#define  USART1_RX_GPIO_PORT            CW_GPIOC
#define  USART1_RX_GPIO_PIN             GPIO_PIN_4



//UART2 GPIO (rx=>PA6 rx=>PA7)
#define  USART2_GPIOA_CLK               RCC_AHB_PERIPH_GPIOA
#define  USART2_GPIO_PORT               CW_GPIOA
#define  USART2_TX_GPIO_PIN             GPIO_PIN_6
#define  USART2_RX_GPIO_PIN             GPIO_PIN_7

//GPIO AF
#define  USART1_AFTX                    PB01_AFx_UART1TXD()
#define  USART1_AFRX                    PC04_AFx_UART1RXD()
#define  USART2_AFTX                    PA06_AFx_UART2TXD()
#define  USART2_AFRX                    PA07_AFx_UART2RXD()



void UART_Init(void);

void UART1_IRQHandlerCallback(void);

void UART2_IRQHandlerCallback(void);

void USART_SendString(UART_TypeDef* USARTx, char *String);


#ifdef __cplusplus
}
#endif

#endif

